import jieba
import wordcloud
from PIL import Image
mask = Image.open("chinamap.jpg")
excludes = {}
with open("关于实施乡村振兴战略的意见.txt", "r", encoding="utf-8") as f:
    t = f.read()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(
    width=1000, height=700,
    background_color="white",
    font_path="msyh.ttc",
    mask=mask
)
# 生成词云图
w.generate(txt)
# 保存词云图
w.to_file("grwordcloudm.png")
